Move notebook to /lib
[andmenj-acm.git] / UVa / 11326 - Laser pointer / 11326.cpp
bloba5aea7dc82a7d161622ee92798e51c7b677d8a4d
1 #include <iostream>
2 #include <cmath>
3 #include <cstdio>
5 using namespace std;
7 int main(){
8 int casos;
9 cin >> casos;
10 while (casos--){
11 int L, W, angleGrad;
12 cin >> L >> W >> angleGrad;
13 //Pasarlo a radianes (2*acos(0) == PI)
14 double angle = 2*acos(0)*angleGrad/180.0;
15 if (angle == 0) printf("1.000\n");
16 else{
17 double x = W / tan(angle);
18 int k = 1;
19 while (x*k <= L) ++k;
20 double y = L - (k-1)*x;
21 double h;
22 if (k % 2 == 0) h = W - y*tan(angle);
23 else h = y*tan(angle);
24 double s = y / cos(angle);
25 double resultado = W/sin(angle)*(k-1);
26 resultado += s;
27 resultado /= sqrt(h*h + L*L);
29 printf("%.3f\n", resultado);
32 return 0;